<template>
  <div id="app">
    <img alt="Vue logo" src="./assets/logo.png">

    <!-- <div> state的数据：{{ $store.state.count }}</div>
    <div> state的数据：{{ $store.state.count }}</div>
    <div> state的数据：{{ $store.state.count }}</div> -->

    <div>11111, {{count}}</div>

    <div>{{ $store.state.list }}</div>
    <div>{{ $store.getters.filterList }}</div>
    <div>{{ filterList }}</div>

    <button @click="addCount(20)">修改count</button>

    <button @click="testFn">异步修改count</button>

    <button @click="asyncAddCount(999)">异步修改count简写</button>

    <hr>

    <h3> {{ $store.state.user.id }} --- {{ $store.getters.idFast }}</h3>
    <h3> {{ $store.state.profile.address }} </h3>

    <button @click="$store.commit('user/updateId')">修改 user的id</button>
    <button @click="updateId">简写 user的id</button>
  </div>
</template>

<script>
import {mapState, mapMutations, mapActions, mapGetters, createNamespacedHelpers} from 'vuex'

const { mapMutations: userMapMutations } = createNamespacedHelpers('user')

export default {
  name: 'App',
  computed: {
    ...mapState(['count']),
    ...mapGetters(['filterList'])
  },
  methods: {
    ...mapMutations(['addCount', 'user/updateId']),
    ...mapActions(['asyncAddCount']),

    ...userMapMutations(['updateId']),
    testFn () {
      this.$store.dispatch('asyncAddCount', 8)
    },
    // changeId() {
    //   // this.$store.commit('user/updateId')

    //   // this.user/updateId()
    //   // this['user/updateId']()

    //   this.updateId()
    // }
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
